package com.poe.service.serviceiImpl.cart;

import com.poe.entity.Cart;
import com.poe.mapperDao.read.cart.ReadCartDao;
import com.poe.mapperDao.write.cart.WriteCartDao;
import com.poe.service.icart.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("cartService")
public class CartServiceImpl implements CartService {
	
	@Autowired
	private ReadCartDao readCartDao;
	@Autowired
	private WriteCartDao writeCartDao;
	@Override
	public boolean addProduct(Cart cart) {
		try {
			writeCartDao.addProduct(cart);
			return true;
		} catch (Exception e) {
			return false;
		}
		
	}

	@Override
	public List<Cart> findAllCart(String userId) {
		return readCartDao.findAllCart(userId);
	}

	@Override
	public boolean deleteProduct(String cartId) {
		try {
			writeCartDao.deleteProduct(cartId);
			return true;
		} catch (Exception e) {
			return false;
		}
		
	}

}
